<template>
  <div class="header wrap">
    <div class="l">
      <h1>
        <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
      </h1>
    </div>
    <div class="c">
      <ul>
        <li
          @click="$router.push('/home')"
          :class="$route.path === '/home' ? 'active' : ''"
        >
          首页
        </li>
        <li
          @click="$router.push('/goods')"
          :class="$route.path === '/goods' ? 'active' : ''"
        >
          全部商品
        </li>
        <li
          @click="$router.push('/user')"
          :class="$route.path === '/user' ? 'active' : ''"
        >
          个人中心
        </li>
        <li
          @click="$router.push('/order')"
          :class="$route.path === '/order' ? 'active' : ''"
        >
          我的订单
        </li>
        <li
          @click="$router.push('/free')"
          :class="$route.path === '/free' ? 'active' : ''"
        >
          专属福利
        </li>
      </ul>
    </div>
    <div class="r">
      <input
        type="text"
        placeholder="请输入关键字"
        v-model="inputSearch"
        @keyup.13="toSearch"
      />
      <span @click="toSearch()"
        ><img width="15" height="15" src="../assets/img/search.png" alt=""
      /></span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      inputSearch: "",
    };
  },
  methods: {
    //搜索栏跳转
    toSearch() {
      //要跳转到goods页面
      this.$router.push(`/goods?keyword=${this.inputSearch}`);
      this.inputSearch = "";
    },
  },
};
</script>
 
<style lang = "less" scoped>
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px auto;
  .c {
    ul {
      width: 500px;
      height: 16px;
      font-size: 16px;
      font-family: SourceHanSansSC;
      font-weight: 500;
      color: #0a328e;
      line-height: 23px;
      display: flex;
      justify-content: space-between;
    }
    li {
      cursor: pointer;
    }
    .active {
      color: #0a328e;
      font-size: 16px;
      font-family: SourceHanSansSC;
      font-weight: 700;
    }
  }
  .r {
    display: flex;
    input {
      width: 214px;
      height: 38px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      text-indent: 14px;
    }
    span {
      width: 50px;
      height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
</style>